package com.ddwl.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author hemiaojun
 * @Date 2020/9/24 20:02
 */
public interface MobileConfigEnum {

    @Getter
    @AllArgsConstructor
    enum RechargeEnum{
        /**
         * 订单关闭
         */
        CLOSED(-1, "订单关闭"),
        /**
         * 创建订单成功
         */
        ORDER_CRE(0, "订单创建成功，等待支付"),
        /**
         * 充值中
         */
        RECHARGING(20, "支付成功，充值中"),
        /**
         * 支付失败
         */
        PAY_FAIL(30, "支付失败"),
        /**
         * 已受理，等带通知是否成功
         */
        ACCEPTED(4,"已受理"),
        /**
         * 受理失败
         */
        ACCEPT_FAIL(40,"受理失败"),
        /**
         * 充值成功
         */
        SUCCESS(2, "充值成功"),
        /**
         * 充值失败
         */
        FAIL(3, "充值失败"),
        /**
         * 退款中
         */
        REFUNDING(5, "退款中"),
        /**
         * 退款成功
         */
        REFUND_SUCCESS(6, "退款成功"),
        /**
         * 退款失败
         */
        REFUND_FAIL(7, "退款失败"),
        ;
        private Integer code;
        private String desc;

        public static String getDescByCode(String code) {
            for (MobileConfigEnum.RechargeEnum rechargeEnum : values()) {
                if (rechargeEnum.getCode().equals(code)) {
                    return rechargeEnum.getDesc();
                }
            }
            return "";
        }

    }

    @Getter
    @AllArgsConstructor
    enum OperatorEnum{
        MOBILE((byte)1, "移动"),
        UNICOM((byte)2, "联通"),
        TELECOM((byte)3, "电信"),
        OTHER((byte)4, "其他"),
        ;
        private Byte code;
        private String name;

        public static String getNameByCode(Byte code) {
            for (MobileConfigEnum.OperatorEnum operatorEnum : values()) {
                if (operatorEnum.getCode().equals(code)) {
                    return operatorEnum.getName();
                }
            }
            return null;
        }
    }

    @AllArgsConstructor
    @Getter
    enum PayStatus {
        CRE( "0", "创建"),
        PRE( "10", "提交"),
        SUCCEED( "20", "支付成功"),
        FAIL( "30", "失败"),
        ;
        private String code;
        private String name;
    }

    @Getter
    @AllArgsConstructor
    enum JDOperatorMatchEnum{
        UNICOM("0", (byte)2),
        MOBILE("1", (byte)1),
        TELECOM("2", (byte)3),
        OTHER("4", (byte)4),
        ;
        private String jdCode;
        private Byte code;

        public static Byte getSystemCode(String jdCode) {
            for (MobileConfigEnum.JDOperatorMatchEnum matchEnum : values()) {
                if (matchEnum.getJdCode().equals(jdCode)) {
                    return matchEnum.getCode();
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    enum BohuanCallEnum{
        /**
         * 下单
         */
        BUY((byte)1, "submitorder"),
        /**
         * 查询余额
         */
        BALANCE((byte)2, "queryBalance"),
        /**
         * 查询订单
         */
        ORDER((byte)3, "queryorder"),
        /**
         * 回调通知
         */
        NOTIFY((byte)4, "notify"),
        ;
        private Byte type;
        private String name;

    }
}
